/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.aaron.platform.view;

import com.aaron.platform.service.IUserService;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

/**
 * 用户会话监听器
 * @author chenzhuohua
 */
public class ItscSessionListener implements HttpSessionListener {

    public void sessionCreated(HttpSessionEvent hse) {

    }

    public void sessionDestroyed(HttpSessionEvent hse) {
        // 调用业务层，清除该用户信息
        ApplicationContext ctx =
                WebApplicationContextUtils.getWebApplicationContext(hse.getSession().getServletContext());
        IUserService userService = (IUserService)ctx.getBean("userService");
        userService.removeUserSession(hse.getSession().getId());
    }

}
